using Microsoft.Win32;
using System;
using System.Diagnostics;
namespace com.haopintui.util
{
	internal class IEVersion
	{
		public static void BrowserEmulationSet()
		{
			string name = Process.GetCurrentProcess().ProcessName + ".exe";
			name = Constants.main_exe;
			try
			{
				RegistryKey localMachine = Registry.LocalMachine;
				RegistryKey registryKey = localMachine.OpenSubKey("SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION", RegistryKeyPermissionCheck.ReadWriteSubTree);
				if (registryKey != null)
				{
					try
					{
						int num = IEVersion.ieVersionEmulation(IEVersion.ieVersion());
						if (num != 0)
						{
							registryKey.SetValue(name, num);
						}
						localMachine.Close();
						Constants.set_ie_boolean = true;
					}
					catch (Exception)
					{
						Constants.set_ie_boolean = false;
					}
				}
			}
			catch (Exception)
			{
				Constants.set_ie_boolean = false;
			}
		}
		private static int ieVersion()
		{
			RegistryKey registryKey = Registry.LocalMachine;
			registryKey = registryKey.CreateSubKey("SOFTWARE\\Microsoft\\Internet Explorer");
			object value = registryKey.GetValue("svcVersion");
			if (value != null)
			{
				registryKey.Close();
				string s = value.ToString().Split(new char[]
				{
					'.'
				})[0];
				return int.Parse(s);
			}
			object value2 = registryKey.GetValue("Version");
			registryKey.Close();
			if (value2 != null)
			{
				string s2 = value2.ToString().Split(new char[]
				{
					'.'
				})[0];
				return int.Parse(s2);
			}
			return 0;
		}
		private static int ieVersionEmulation(int ieVersion)
		{
			if (ieVersion < 8)
			{
				return 0;
			}
			if (ieVersion == 8)
			{
				return 8000;
			}
			if (ieVersion == 9)
			{
				return 9000;
			}
			if (ieVersion == 10)
			{
				return 10000;
			}
			if (ieVersion == 11)
			{
				return 11000;
			}
			return 0;
		}
	}
}
